/***************************************************************************
 *            crypt_test.c
 *
 *  Thu May 24 11:22:05 2007
 *  Copyright  2007  kf701
 *  Email <kf701.ye AT gmail.com>
 ****************************************************************************/

#include "factory.h"

int main()
{
	debug_verbose = 4;

	int ret = 0;

	char dest[128];
	char decry[128];
	char buf[16];

	rand_string( buf, sizeof(buf) );
	bin2hex( dest, buf, sizeof(buf) );
	sys_debug("rand str(hex) = %s\n", dest);

	ret = encode_b64( dest, buf, sizeof(buf) );
	sys_debug("ret = %d,en_b64 = %s\n", ret, dest);
	ret = decode_b64( decry, dest, strlen(dest) );
	bin2hex( dest, decry, ret );
	sys_debug("ret = %d,de_b64(hex) = %s\n", ret, dest );

	char key[64] = "ubuntu";
	char *ret1, *ret2;
	ret1 = crypt( key, "ab" );
	printf("ret1 = %s\n", ret1);
	ret2 = crypt( key, "ab" );
	printf("ret2 = %s\n", ret2);

	rand_string( key, sizeof(key) );
	ret1 = crypt( key, "ab" );
	printf("ret1 = %s\n", ret1);
	ret2 = crypt( key, "ab" );
	printf("ret2 = %s\n", ret2);
	
}
